# coding=utf-8

from datetime import timedelta
import os
import configparser
from fly2018.settings import log_common

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


main_cf = configparser.ConfigParser()
main_cf.read(BASE_DIR + '/../conf/main.ini')


rabbitMq_host = main_cf.get('rabbit_mq', 'rabbit_mq_host')
rabbitMq_port = main_cf.get('rabbit_mq', 'rabbit_mq_port')
rabbitMq_user = main_cf.get('rabbit_mq', 'rabbit_mq_user')
rabbitMq_pwd = main_cf.get('rabbit_mq', 'rabbit_mq_pwd')
BROKER_URL = 'amqp://' + rabbitMq_user + ':' + rabbitMq_pwd + '@' + rabbitMq_host + ':' + rabbitMq_port
log_common.info('消息中间人:BROKER_URL = %s' % BROKER_URL)


CELERY_RESULT_BACKEND = 'db+sqlite:///' + os.path.join(BASE_DIR, '../run/celery_results.sqlite')
CELERY_TIMEZONE = 'UTC'


CELERYBEAT_SCHEDULE = {
    'dispatch_data_job': {
        'task': 'fly2018.dispatch_dc_data',
        'schedule': timedelta(seconds=60),
        'args': ()
    },
    'sync_29_job': {
        'task': 'fly2018.sync_29_data',
        'schedule': timedelta(seconds=180),
        'args': ()
    }
}

